package com.hpeng.sys.dao.impl;

import java.util.List;
import org.springframework.stereotype.Component;
import com.hpeng.sys.dao.SysLoggerDao;
import com.hpeng.sys.model.SysLogger;
import com.hpeng.util.GenericDaoImpl;
import com.hpeng.util.Pagination;

@Component("SysLoggerDao")
public class SysLoggerDaoImpl extends GenericDaoImpl<SysLogger, Integer> implements SysLoggerDao {
	public List<SysLogger> getLogger(String userCode) {
		String hql = "from SysLogger s ";
		if(userCode != null && !userCode.equals("")){
			hql+=" where s.UserCode = '"+userCode+"' ";
		}
		List<SysLogger> loggerList = getByHql(hql);
		return loggerList;
	}

	public Pagination<SysLogger> getPagination(int pageNumber, String[] hql,
			String order) {
		Pagination<SysLogger> pagination = null;
		StringBuffer sb = new StringBuffer();
		try {
			for (String str : hql) {
				sb.append(str);
			}
			pagination = this.getPagination(sb.toString() + order, null, pageNumber);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return pagination;
	}
	
}
